<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒排索引：全文检索的核心技术</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 3.5rem;
            padding-right: 0.5rem;
            margin-top: 0.25rem;
            font-weight: 700;
            color: #4338ca;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 代码块样式 */
        .code-block {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 1.5rem;
            border-radius: 1rem;
            font-family: 'Courier New', monospace;
            position: relative;
            overflow: hidden;
        }
        
        .code-block::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: shimmer 3s infinite;
        }
        
        @keyframes shimmer {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        /* 卡片悬停效果 */
        .hover-card {
            transition: all 0.3s ease;
            cursor: pointer;
        }
        
        .hover-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        /* 标题装饰线 */
        .title-decoration {
            position: relative;
            display: inline-block;
        }
        
        .title-decoration::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, #4338ca 0%, #7c3aed 100%);
            border-radius: 2px;
        }
        
        /* 引用样式 */
        .quote-box {
            position: relative;
            padding-left: 3rem;
        }
        
        .quote-box::before {
            content: '"';
            position: absolute;
            left: 0;
            top: -1rem;
            font-size: 4rem;
            color: #e0e7ff;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 数字标记样式 */
        .number-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 2.5rem;
            height: 2.5rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 50%;
            font-weight: 700;
            margin-right: 1rem;
        }
        
        /* 渐变文字 */
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* 动画入场效果 */
        .fade-in {
            animation: fadeIn 0.8s ease-out;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* Mermaid 图表样式 */
        .mermaid {
            background: white;
            padding: 2rem;
            border-radius: 1rem;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <section class="relative overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 text-white">
        <div class="absolute inset-0 bg-black opacity-20"></div>
        <div class="relative container mx-auto px-6 py-24 text-center">
            <h1 class="text-5xl md:text-7xl font-bold mb-6 fade-in">
                倒排索引
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90 fade-in" style="animation-delay: 0.2s;">
                <i class="fas fa-search mr-2"></i>
                全文检索系统的核心技术
            </p>
            <div class="max-w-3xl mx-auto text-lg leading-relaxed opacity-80 fade-in" style="animation-delay: 0.4s;">
                倒排索引（Inverted Index）是一种革命性的数据结构，它颠覆了传统的文档检索方式，
                让我们能够在海量数据中以闪电般的速度找到所需信息。
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0">
            <svg viewBox="0 0 1440 120" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M0 120L60 110C120 100 240 80 360 70C480 60 600 60 720 65C840 70 960 80 1080 85C1200 90 1320 90 1380 90L1440 90V120H1380C1320 120 1200 120 1080 120C960 120 840 120 720 120C600 120 480 120 360 120C240 120 120 120 60 120H0V120Z" fill="white"/>
            </svg>
        </div>
    </section>

    <!-- 主要内容区域 -->
    <main class="container mx-auto px-6 py-12 max-w-6xl">
        
        <!-- 原理介绍 -->
        <section class="mb-16 fade-in">
            <h2 class="text-4xl font-bold mb-8 text-gray-800">
                <span class="title-decoration">倒排索引的原理</span>
            </h2>
            <div class="bg-white rounded-2xl shadow-xl p-8 hover-card">
                <p class="text-lg leading-relaxed text-gray-700 mb-6 drop-cap">
                    倒排索引（Inverted Index）是一种高效的索引结构，广泛应用于全文检索系统中。与传统的正向索引（Forward Index）不同，倒排索引是根据文档内容创建索引，以便快速查找包含特定关键词的文档。倒排索引将文档与包含的词语之间的关系进行了逆向存储，从而提高查询效率。
                </p>
                
                <!-- 概念对比图 -->
                <div class="grid md:grid-cols-2 gap-6 mt-8">
                    <div class="bg-gradient-to-br from-blue-50 to-indigo-100 p-6 rounded-xl">
                        <h3 class="text-xl font-bold text-indigo-800 mb-3">
                            <i class="fas fa-file-alt mr-2"></i>正向索引
                        </h3>
                        <p class="text-gray-700">文档 → 词汇列表</p>
                        <p class="text-sm text-gray-600 mt-2">传统方式：从文档找词汇</p>
                    </div>
                    <div class="bg-gradient-to-br from-purple-50 to-pink-100 p-6 rounded-xl">
                        <h3 class="text-xl font-bold text-purple-800 mb-3">
                            <i class="fas fa-exchange-alt mr-2"></i>倒排索引
                        </h3>
                        <p class="text-gray-700">词汇 → 文档列表</p>
                        <p class="text-sm text-gray-600 mt-2">高效方式：从词汇找文档</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 基本结构 -->
        <section class="mb-16 fade-in">
            <h2 class="text-4xl font-bold mb-8 text-gray-800">
                <span class="title-decoration">倒排索引的基本结构</span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-2xl shadow-xl p-8 hover-card">
                    <div class="flex items-center mb-4">
                        <span class="number-badge">1</span>
                        <h3 class="text-2xl font-bold gradient-text">词典（Dictionary）</h3>
                    </div>
                    <p class="text-gray-700 leading-relaxed">
                        存储所有出现过的词汇，每个词汇对应一个唯一的ID或直接作为词条。
                    </p>
                </div>
                
                <div class="bg-white rounded-2xl shadow-xl p-8 hover-card">
                    <div class="flex items-center mb-4">
                        <span class="number-badge">2</span>
                        <h3 class="text-2xl font-bold gradient-text">倒排表（Posting List）</h3>
                    </div>
                    <p class="text-gray-700 leading-relaxed mb-4">
                        记录每个词汇出现的文档ID及其在文档中的位置。倒排表通常包含：
                    </p>
                    <ul class="space-y-2">
                        <li class="flex items-center text-gray-600">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            文档ID（Document ID）
                        </li>
                        <li class="flex items-center text-gray-600">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            词汇在文档中的位置（Position）
                        </li>
                        <li class="flex items-center text-gray-600">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            词频（Term Frequency）
                        </li>
                    </ul>
                </div>
            </div>
            
            <!-- 示例展示 -->
            <div class="mt-12 bg-gradient-to-r from-indigo-50 to-purple-50 rounded-2xl p-8">
                <h3 class="text-2xl font-bold text-gray-800 mb-6">
                    <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                    实例演示
                </h3>
                
                <div class="grid md:grid-cols-3 gap-4 mb-8">
                    <div class="bg-white p-4 rounded-lg shadow">
                        <h4 class="font-bold text-indigo-600 mb-2">Doc1</h4>
                        <p class="text-gray-700">"the quick brown fox"</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow">
                        <h4 class="font-bold text-indigo-600 mb-2">Doc2</h4>
                        <p class="text-gray-700">"the quick brown dog"</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow">
                        <h4 class="font-bold text-indigo-600 mb-2">Doc3</h4>
                        <p class="text-gray-700">"the brown fox jumped over the lazy dog"</p>
                    </div>
                </div>
                
                <div class="bg-white rounded-lg p-6">
                    <h4 class="font-bold text-gray-800 mb-4">倒排索引结构：</h4>
                    <div class="space-y-2 font-mono text-sm">
                        <div class="flex items-center">
                            <span class="text-purple-600 font-bold w-24">"the"</span>
                            <i class="fas fa-arrow-right mx-4 text-gray-400"></i>
                            <span class="text-gray-700">{Doc1, Doc2, Doc3}</span>
                        </div>
                        <div class="flex items-center">
                            <span class="text-purple-600 font-bold w-24">"quick"</span>
                            <i class="fas fa-arrow-right mx-4 text-gray-400"></i>
                            <span class="text-gray-700">{Doc1, Doc2}</span>
                        </div>
                        <div class="flex items-center">
                            <span class="text-purple-600 font-bold w-24">"brown"</span>
                            <i class="fas fa-arrow-right mx-4 text-gray-400"></i>
                            <span class="text-gray-700">{Doc1, Doc2, Doc3}</span>
                        </div>
                        <div class="flex items-center">
                            <span class="text-purple-600 font-bold w-24">"fox"</span>
                            <i class="fas fa-arrow-right mx-4 text-gray-400"></i>
                            <span class="text-gray-700">{Doc1, Doc3}</span>